<?php require ("../header.php"); ?>
<?php
	//check if user to meet requirement permission.  If not it will be redirect to appropriate page.
	if ($ad_check<1){
			header ("Location:../login.php?action=0");
		} 
		if ($ad_check==1) {
			echo "<br><br><br><br><br><b><br><center>You do not have privillage to register lecturers.</center></b>";
			echo "<br><br><br><br><br><b><br><br>";
			echo "<META http-equiv=\"refresh\" content=\"2;URL=admin.php?action=102\">";
		}
		else {
	
	//start process of insert subject data into database
	if (isset($_POST['sub_name'])) {
		$sub_name=$_POST['sub_name'];
	}
	if (isset($_POST['sub_code'])) {
		$sub_code=$_POST['sub_code'];
	}
	if (isset($_POST['sub_department'])) {
		$sub_department=$_POST['sub_department'];
	}
	
	if ($sub_name!=NULL && $sub_code!=NULL && $sub_department!=NULL) {
		$sql_insert_subject="INSERT INTO subject (sub_name,sub_code,sub_department)
							VALUES ('$sub_name','$sub_code','$sub_department')";
		$insert_subject=mysql_query($sql_insert_subject) or die ("Cannot register subject.  Please contact system programmer");
		echo "<br><br><br><br><br><b><br><br><center><b><center>Registration is complete.  You will be redirect to admin page.</b></center>";
		echo "<br><br><br><br><br><br><br><br><br>";
		echo "<META http-equiv=\"refresh\" content=\"2;URL=../admin.php\">";
	}
	else {
		echo "<br><br><br><br><br><b><br><br><center><b><center>Registration Failed.  Please fill all detail before submit.</b></center>";
		echo "<br><br><br><br><br><br><br><br><br>";
		echo "<META http-equiv=\"refresh\" content=\"2;URL=../subject_reg.php\">";
	}
?>
<?php } ?>

<?php require ("../footer.php"); ?>